package com.jsyl.lwbk.business.service.impl;

import com.jsyl.lwbk.business.domain.ClassPlan;
import com.jsyl.lwbk.business.mapper.ClassPlanMapper;
import com.jsyl.lwbk.business.service.ClassPlanService;
import com.jsyl.lwbk.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Fitch
 * 2022/2/21
 */
@Service
public class ClassPlanServiceImpl implements ClassPlanService {
    @Autowired
    private ClassPlanMapper classPlanMapper;
    @Override
    public List<ClassPlan> findList(ClassPlan classPlan) {
        List<ClassPlan> list =classPlanMapper.findList(classPlan.getCourseId(),classPlan.getClassType(),classPlan.getAgeGrade());
        return list;
    }

    @Override
    public int updateStatus(ClassPlan classPlan) {
        return this.classPlanMapper.update(classPlan);
    }

    @Override
    public int checkPlanNameUnique(ClassPlan classPlan) {
        return this.classPlanMapper.checkPlanNameUnique(classPlan.getPlanName(),classPlan.getAgeGrade())>0?1:0;
    }

    @Override
    public int addClassPlan(ClassPlan classPlan) {
//        classPlan.setId(String.IdWorker.getId());
        classPlan.setCreateTime(DateUtils.getNowDate());
        return this.classPlanMapper.insert(classPlan);
    }
}
